let QcloudSms = require("qcloudsms_js");
//数据读取json
let config = {
    "appid":"1400503958",
    "appkey":"d56b2b2c8008013ba34558a01b264adb",
    "smssign":"泗科智能"
};
//短信发送工具类
module.exports = function (phoneNumber,templateId,params){
    // 实例化QcloudSms
    let qcloudsms = QcloudSms(config.appid, config.appkey);
    let smsType = 0;
    let ssender = qcloudsms.SmsSingleSender();
    return new Promise(function(resolve,reject){
        console.log('短信接受号码:'+phoneNumber);
        console.log('模版ID:'+templateId);
        console.log('模版变量:'+params);
        ssender.sendWithParam(86, phoneNumber.split(','), templateId,params, config.smssign, "", "", function(err,res,resData){
            if (err) {
                reject();//发送失败
            } else {
                //所有短信全部认定发送成功
                console.log(resData);
                resolve(true);
            }
        });
    });
};
